package com.it.singleDocument;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngineConfiguration;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.repository.Deployment;
import org.junit.Test;

import java.io.InputStream;
import java.util.zip.ZipInputStream;

public class deployProcessByZip {

    @Test
    public void test01() {

        InputStream inputStream = this.getClass()
                .getClassLoader()
                .getResourceAsStream(" diagram/diagram.zip");

        ZipInputStream zipInputStream = new ZipInputStream(inputStream);
        //repository
        ProcessEngineConfiguration configuration =
                ProcessEngineConfiguration
                        .createProcessEngineConfigurationFromResource("activiti.cfg.xml");
        ProcessEngine processEngine =
                configuration.buildProcessEngine();
        System.out.println(processEngine);
        // 获取repositoryService
        RepositoryService repositoryService = processEngine
                .getRepositoryService();

        Deployment deployment = repositoryService.createDeployment()//
                .addZipInputStream(zipInputStream).deploy();
        System.out.println("deployment = " + deployment.getClass());

        System.out.println("deployment.getId() = " + deployment.getId());
        System.out.println("deployment.getName() = " + deployment.getName());


    }
}
